package com.zz.cinema.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * 
 * @author francis.zhang01
 *
 */
@Entity
@Table(name = "TS_CINEMA")
public class TS_Cinema {
	
	/**
	 * create sequence SEQ_TS_CINEMA 
	 * minvalue 90000 
	 * maxvalue 99999
	 * start with 90000
	 * increment by 1
	 * cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_CINEMA", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_CINEMA", sequenceName = "SEQ_TS_CINEMA", initialValue = 90000, allocationSize = 1)
	private int cinemaId;
	
	private String cinemaName;
	
	private String address;
	
	private int grade; //等级 1-5
	
	@OneToMany(mappedBy="cinema", targetEntity = TS_Hall.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<TS_Hall> halls = new HashSet<>();
	
	@OneToMany(mappedBy="cinema", targetEntity = TS_ItemON.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private Set<TS_ItemON> itemONs = new HashSet<>();
	
	public TS_Cinema() {
		super();
	}

	public TS_Cinema(int cinemaId, String cinemaName, String address, int grade) {
		super();
		this.cinemaId = cinemaId;
		this.cinemaName = cinemaName;
		this.address = address;
		this.grade = grade;
	}

	public int getCinemaId() {
		return cinemaId;
	}

	public void setCinemaId(int cinemaId) {
		this.cinemaId = cinemaId;
	}

	public String getCinemaName() {
		return cinemaName;
	}

	public void setCinemaName(String cinemaName) {
		this.cinemaName = cinemaName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	public Set<TS_Hall> getHalls() {
		return halls;
	}

	public void setHalls(Set<TS_Hall> halls) {
		this.halls = halls;
	}

	public Set<TS_ItemON> getItemONs() {
		return itemONs;
	}

	public void setItemONs(Set<TS_ItemON> itemONs) {
		this.itemONs = itemONs;
	}

	@Override
	public String toString() {
		return "TS_Cinema [cinemaId=" + cinemaId + ", cinemaName=" + cinemaName + ", Address=" + address + ", Grade="
				+ grade + ", halls=" + halls + ", itemONs=" + itemONs + "]";
	}
	
}
